'''
利用等差数列求和公式
滑动窗口 滑动首相和尾项
'''
# -*- coding:utf-8 -*-
class Solution:
    def FindContinuousSequence(self, tsum):
        # write code here
        head = 1
        tail = 2
        res = []
        while head < tail:
            if ( head+ tail )*(tail - head + 1)/2 < tsum:
                tail += 1
            if ( head+ tail )*(tail - head + 1)/2 > tsum:
                head += 1
            if ( head+ tail )*(tail - head + 1)/2 == tsum:
                res.append(list(range(head,tail+1)))
                head += 1
        return res
'''
暴力遍历，需要用sort库，not good
结合等差数列求和
'''
class Solution:
    def FindContinuousSequence(self, tsum):
        # write code here
        res=[]
        if tsum<=2:
            return []
        for n in range(2,tsum+1):
            temp=tsum-n*(n-1)//2
            if temp<=0:
                break
            if not temp%n:
                start=temp//n
                res.append([start+i for i in range(n)])
        return res[::-1]